﻿using System;
using System.Collections.Generic;
using System.Text;
using ObjectSync.Interfaces;

namespace ObjectSync
{
    [Serializable]
    public abstract class SyncableObject: ISyncable 
    {
        private int netId;
        protected List<string> syncableProps = new List<string>();

        protected SyncableObject()
        {
            netId = SyncManager.Instance.NextNetID;
        }

        /// <summary>
        /// Unique object identification so the network server can reconize him
        /// </summary>
        public int NetId
        {
            get { if (netId == 0) netId = SyncManager.Instance.NextNetID;
                return netId;}
            set { netId = value; }
        }

        public string[] SyncableProps
        {
            get { return syncableProps.ToArray(); }
        }

        public ISyncable Copy()
        {
            return (ISyncable)this.MemberwiseClone();
        }
    }
}
